package com.ysx.common.utils;

import com.ysx.common.constants.SystemConstants;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

public class RequestHeaderInfoUtils {
    public static String getHeaderUserId() {
        //从请求头中获取用户id
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        return requestAttributes.getRequest().getHeader(SystemConstants.WEMEDIA_HEADER_USERID);
    }

    //判断是否为匿名用户
    public static boolean isAnonymous(){
        String userInfo = getHeaderUserId();
        if("0".equals(userInfo)){
            return true;
        }
        return false;
    }


}
